<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        /*
        1.定义类
        2.构造函数
        3.定义resolve,reject方法
        4.回调函数
    */
        class HMpPromise {
            constructor(executor) {
                const resolve = (result) => {
                    console.log('resolve', result)
                }
                const reject = (result) => {
                }

                executor(resolve, reject)
            }
        }

        const p = new HMpPromise((resolve, reject) => {
            console.log('执行器函数被调用')
            resolve('成功')
            reject('失败')
        })
    </script>
</body>

</html>